<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit"/>
  <meta name="force-rendering" content="webkit"/>
  <!-- import CSS -->
  <link rel="stylesheet" href="../js/3rd/elementUi/index.css">
  <link rel="stylesheet" href="../css/pc.css">
  <script src="../js/3rd/elementUi/vue.js"></script>
  <script src="../js/3rd/jquery-3.1.1.min.js"></script>
</head>
<body>
  <div id="projectLists" class="project-lists">
    
	<el-container>
	  <el-aside class="sider-bar" id="siderbar">
      <div class="logo"><img src="../image/logo.jpg">来赚吧管理后台</div> 
	    <tp-siderbar title="发布项目"></tp-siderbar>
	  </el-aside>
    <el-main>
	  <div class="right-content">
      <el-breadcrumb separator-class="el-icon-arrow-right" class="bread-bd">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>项目列表</el-breadcrumb-item>
      </el-breadcrumb>
      <template>
        <el-table
          :data="applyUserData"
          style="width: 100%">
          <el-table-column
            label="账号(手机号)"
            width="180">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.telephone }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="金额"
            width="180">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.score }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="姓名"
            width="180">
            <template slot-scope="scope">
              <span>{{ scope.row.bankPerson }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="审核状态"
            width="180">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.status|status }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="转账类型"
            width="180">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.payType|type }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="账号"
            width="200">
            <template slot-scope="scope">
              <span v-if="scope.row.payType!==3">{{ scope.row.account }}</span>
              <span v-if="scope.row.payType==3">银行名：{{ scope.row.bankName }}</br>银行卡：{{ scope.row.bankNo }}</br>开户人：{{ scope.row.bankPerson }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="申请时间"
            width="180">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.createTime|formatData}}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                size="mini"
                @click="handleCheckUser(scope.$index, scope.row)">编辑</el-button>              
            </template>
          </el-table-column>
        </el-table>
      </template> 

      <div class="clearfix"></div>
    </div>  
   </el-main>  
	</el-container>

  <el-dialog title="请审核状态" :visible.sync="dialogFormVisible">
    <el-form >
      <el-form-item label="审核状态" :label-width="formLabelWidth">
        <el-select v-model="selectStatusVal" placeholder="请选择目前状态">
          <el-option label="同意" value="1"></el-option>
          <el-option label="拒绝" value="9"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitHandleCheckUser()">确 定</el-button>
    </div>
  </el-dialog>

  </div>
</body>


  <!-- import JavaScript -->
  <script src="../js/3rd/elementUi/index.js"></script>
  <script src="../js/js/admin_siderbar.js"></script>
  <script src="../js/js/common.js"></script>
  <script>
   var token=getCookie("userToken");
   var userId=getCookie("userId");

   if(!token||!userId){
      window.location.href = "/admin/login.html";
   }
  
  var url=window.location.hash;
  var projectId=url.split("#")[1];
  console.log(projectId)

    new Vue({
      el: '#projectLists',
      data: {
        applyUserData:[],
        selectStatusVal:'',
        selectRowContent:'',
        selectIndex:'',
        dialogFormVisible:false,
        formLabelWidth: '120px',
        isDoingSubmitHandle:false,
      },
      created:function(){
         var getApplyUrl="/cashOut/getCashOutApply ";
         var data={
                   page: 1,
                   size: 20,
                   telephone: "",
                   status:"",
                   token: token,
                   userId: parseInt(userId),
                   client: 3,
         }
         pushData(getApplyUrl,data,function(res){
             console.log(res)
             if(res.errorCode=="008"){
               window.location.href = "/admin/login.html";
             }
             this.applyUserData=res.data.CashOut;
         }.bind(this))
      },
      filters:{
        type: function (key) {
            key = parseInt(key);
            var map = {
                1: "支付宝",
                2: "微信",
                3: "银行卡",       
            };
            return map[key];
        },
        status: function (key) {
            key = parseInt(key);
            var map = {
                1: "成功",
                0: "申请中", 
                9: "拒绝",      
            };
            return map[key];
        },
        formatData:function(key){
          return formatDate(key)
        }
      },
      methods:{
      
          handleCheckUser:function(index,row){
            console.log(index);
            console.log(row);
            this.dialogFormVisible=true;
            this.selectRowContent=row;
            this.selectIndex=index;
            
          },  
          submitHandleCheckUser:function(){
            if(this.isDoingSubmitHandle){
              return ;
            }
            this.isDoingSubmitHandle=true;
            if(this.selectStatusVal==1){
              var url="/cashOut/checkSuccess ";
            }else if(this.selectStatusVal==9){
              var url="/cashOut/reject ";
            }
            
            var data={
                client: 3,
                id: parseInt(this.selectRowContent.id),
                token: token,
                userId: parseInt(userId)
            }
            console.log(data)
            pushData(url,data,function(res){
              this.isDoingSubmitHandle=false;
              if(res.state){
                console.log(res);
                this.applyUserData[this.selectIndex].status=this.selectStatusVal;
                this.dialogFormVisible=false;
              }else{
                alert(res.message)
              }
            }.bind(this))

          }

        }

      
    })
  </script>
</html>